//#pragma once

#ifndef __STRING_H__
#define __STRING_H__


#include <iostream>
using namespace std;

#include <assert.h>


namespace yyp
{
	class string
	{
	public:
		typedef char* iterator;

	public:
		string(const char* s = "");
		string(const string& str);
		~string()
		{
			delete[] _str;
			_str = nullptr;
			_size = _capacity = 0;
		}

		//iterator
		iterator begin() const
		{
			return _str;
		}

		iterator end() const
		{
			return _str + _size;
		}
		
		// modify
		/*void push_back(char c);
		string& operator+=(char c)
		void append(const char* str);
		string& operator+=(const char* str);
		void clear();
		void swap(string& s);
		const char* c_str()const;*/
		void push_back(char c);
		string& operator+=(char c);
		string& operator+=(const string& str);
		string& append(const string& str);
		void clear();
		void swap(const string& s);//err
		const char* c_str() const
		{
			return _str;
		}

		string& operator=(const string& str);

		

		size_t capacity() const
		{
			return _capacity;
		}

		size_t size() const
		{
			return _size;
		}

		void reserve(size_t n = 0);

		

		

		//static const size_t npos;

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	};

	//const size_t string::npos = -1;


	
}





#endif
